home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_mysql.idb / usr / freeware / include / mysql / chardefs.h.z / chardefs.h
Encoding:
C/C++ Source or Header  |  1999-10-18  |  3.8 KB  |  143 lines

  1. /* chardefs.h -- Character definitions for readline. */
  2.  
  3. /* Copyright (C) 1994 Free Software Foundation, Inc.
  4.  
  5.    This file is part of the GNU Readline Library, a library for
  6.    reading lines of text with interactive input and history editing.
  7.  
  8.    The GNU Readline Library is free software; you can redistribute it
  9.    and/or modify it under the terms of the GNU General Public License
  10.    as published by the Free Software Foundation; either version 1, or
  11.    (at your option) any later version.
  12.  
  13.    The GNU Readline Library is distributed in the hope that it will be
  14.    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15.    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    The GNU General Public License is often shipped with GNU software, and
  19.    is generally kept in a file called COPYING or LICENSE.  If you do not
  20.    have a copy of the license, write to the Free Software Foundation,
  21.    675 Mass Ave, Cambridge, MA 02139, USA. */
  22.  
  23. #ifndef _CHARDEFS_H_
  24. #define _CHARDEFS_H_
  25.  
  26. #ifndef _m_ctype_h            /* Conflict on BSDI */
  27. #include <ctype.h>
  28. #endif
  29.  
  30. #if defined (HAVE_CONFIG_H)
  31. #  if defined (HAVE_STRING_H)
  32. #    include <string.h>
  33. #  else
  34. #    include <strings.h>
  35. #  endif /* HAVE_STRING_H */
  36. #else
  37. #  include <string.h>
  38. #endif /* !HAVE_CONFIG_H */
  39.  
  40. #ifndef whitespace
  41. #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  42. #endif
  43.  
  44. #ifdef CTRL
  45. #undef CTRL
  46. #endif
  47.  
  48. /* Some character stuff. */
  49. #define control_character_threshold 0x020   /* Smaller than this is control. */
  50. #define control_character_mask 0x1f        /* 0x20 - 1 */
  51. #define meta_character_threshold 0x07f        /* Larger than this is Meta. */
  52. #define control_character_bit 0x40        /* 0x000000, must be off. */
  53. #define meta_character_bit 0x080        /* x0000000, must be on. */
  54. #define largest_char 255            /* Largest character value. */
  55.  
  56. #define CTRL_CHAR(c) (((unsigned char) c) < control_character_threshold)
  57. #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
  58.  
  59. #define CTRL(c) ((c) & control_character_mask)
  60. #define META(c) ((c) | meta_character_bit)
  61.  
  62. #define UNMETA(c) ((c) & (~meta_character_bit))
  63. #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
  64.  
  65. /* Old versions
  66. #define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
  67. #define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
  68. #define _rl_digit_p(c)  ((c) >= '0' && (c) <= '9')
  69. */
  70.  
  71. #define _rl_lowercase_p(c) (islower(c))
  72. #define _rl_uppercase_p(c) (isupper(c))
  73. #define _rl_digit_p(x)  (isdigit (x))
  74.  
  75. #define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c))
  76. #define ALPHABETIC(c)    (_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c))
  77.  
  78. /* Old versions
  79. #  define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c))
  80. #  define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c))
  81. */
  82.  
  83. #ifndef _rl_to_upper
  84. #  define _rl_to_upper(c) (islower(c) ? toupper(c) : (c))
  85. #  define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c))
  86. #endif
  87.  
  88. #ifndef _rl_digit_value
  89. #define _rl_digit_value(x) ((x) - '0')
  90. #endif
  91.  
  92. #ifndef NEWLINE
  93. #define NEWLINE '\n'
  94. #endif
  95.  
  96. #ifndef RETURN
  97. #define RETURN CTRL('M')
  98. #endif
  99.  
  100. #ifndef RUBOUT
  101. #define RUBOUT 0x7f
  102. #endif
  103.  
  104. #ifndef TAB
  105. #define TAB '\t'
  106. #endif
  107.  
  108. #ifdef ABORT_CHAR
  109. #undef ABORT_CHAR
  110. #endif
  111. #define ABORT_CHAR CTRL('G')
  112.  
  113. #ifdef PAGE
  114. #undef PAGE
  115. #endif
  116. #define PAGE CTRL('L')
  117.  
  118. #ifdef SPACE
  119. #undef SPACE
  120. #endif
  121. #define SPACE ' '    /* XXX - was 0x20 */
  122.  
  123. #ifdef ESC
  124. #undef ESC
  125. #endif
  126. #define ESC CTRL('[')
  127.  
  128. #ifndef ISOCTAL
  129. #define ISOCTAL(c)      ((c) >= '0' && (c) <= '7')
  130. #endif
  131. #define OCTVALUE(c)     ((c) - '0')
  132.  
  133. #ifndef isxdigit
  134. #  define isxdigit(c)   (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
  135. #endif
  136.  
  137. #define HEXVALUE(c) \
  138.   (((c) >= 'a' && (c) <= 'f') \
  139.       ? (c)-'a'+10 \
  140.       : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
  141.  
  142. #endif  /* _CHARDEFS_H_ */
  143.